package com.paxcodi.sockets.helloworld;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class ServiceHandler {
    public ServiceHandler(Socket socket) {
	try {
	    System.out.println("server: ServiceHandler started ...");
	    BufferedReader in = new BufferedReader(
		    new InputStreamReader(socket.getInputStream()));
	    PrintWriter out = new PrintWriter(socket.getOutputStream());

	    String msg = in.readLine();
	    out.println(msg);
	    out.flush();
	    
	    socket.close();
	    
	} catch(IOException e){
	    System.out.println("socket within ServiceHandler blew up " + e);
	}
    }
}